package it.blog.controller;


import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import it.blog.stub.*;


public class CategoryBlogView extends HttpServlet{

	
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -8689739037365298303L;

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		HttpSession session = request.getSession();
		BlogPortal bp = new BlogPortalService().getPort(BlogPortal.class);
		Integer id = Integer.parseInt(request.getParameter("categoryID"));

		List<Blog> listBlogOfCategory = bp.getBlogsOfCategory(id);
		List<BlogCategory>blogCategoryList = bp.getBlogCategoryList();
		
		session.setAttribute("listBlogOfCategory",listBlogOfCategory);
		
		session.setAttribute("blogCategoryList",blogCategoryList);
		session.removeAttribute("mess");
		response.sendRedirect(response.encodeRedirectURL(request.getContextPath()+"/home.jsp?kop=blogcategory"));
	
	}
	
	

	
	
}
